#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include"musiclist.h"
#include<QMediaPlaylist>
namespace Ui {
class CommonPage;
}

extern QMap<QString,QPixmap> g_cover_cache;//全局静态缓存

enum MusicListType{
    LIKE_LIST,
    LOCAL_LIST,
    HISTORY_LIST,
    NET_LIST
};

class CommonPage : public QWidget
{
    Q_OBJECT

public:

    explicit CommonPage(QWidget *parent = nullptr);
    ~CommonPage();

     void setMusicListType(MusicListType type);

    void setCommonUi(const QString&text,const QString&imagePath);

    void addMusicToMusicPage(MusicList& musicList);

    void reFresh(MusicList&musicList);

    //添加到播放列表
    void addMusicToPlaylist(MusicList&musicList,QMediaPlaylist*playList);
    QString getMusicIdByIndex(int index);

    void setMusicImage(QPixmap pixmap);

    void setCommonUi_Net(const QString &text, const QPixmap &imagePath);

    MusicListType getPageListType();

signals:
    void updateLikeMusic(bool isLike,const QString&musicId);
    void playAll(MusicListType);
    void playMusicByIndex(CommonPage*,int);

private:
    Ui::CommonPage *ui;
    MusicListType musicListType;

    QVector<QString> musicOfPage;

};

#endif // COMMONPAGE_H
